﻿<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<link rel="stylesheet" type="text/css" media="screen" href="css/smoothness/jquery-ui-1.10.3.custom.min.css" />	<!-- jqueryUI CSS -->
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />							<!-- jqGrid CSS -->
<link rel="stylesheet" type="text/css" media="screen" href="css/selfTemplate.css" />						<!-- 本專案自行定義 CSS -->

<script src="js/jquery-1.9.1.min.js"></script>		<!-- jQuery 核心 -->
<script src="js/grid.locale-tw.js" type="text/javascript"></script>											<!-- jqGrid 語系檔 -->
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>										<!-- jqGrid 核心 -->
<script src="js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>							<!-- jqueryUI 核心 -->
<script src="js/jquery.cookie.js" type="text/javascript"></script>																<!-- 操作cookie用 -->
<script src="js/widgets.js" type="text/javascript"></script>							<!-- jqueryUI 核心 -->

<title>維護Web Console List</title>

<script type="text/javascript">

$(document).ready(function() {
	
	if ($.cookie("userId") == null) {
		alert("請先登入系統");
		location.assign("index.html");
	} else {
		$("#a_form #loginUser").val( $.cookie("userId") );
		$("#a_form #isSU").val( $.cookie("isSU") );
		/*	先查詢有那些子系統供 Select	*/
		querySubSys("squad");
		
		/*	綁定 下拉吧 選擇的事件 */ 
		
		selectSubSys("QueryWCL");
		
		$("#gd").jqGrid({
		   	colNames:["WebConsole序號","IP","模組置放路徑","登入帳號","登入密碼"],
		   	colModel:[
		   		{name:"webconsolesn",index:"webconsolesn",editable:false,hidden: true, hidedlg: true, editrules:{edithidden:true}}
		   		,{	/*	IP	*/
		   			name:"webconsoleip",
		   			index:"webconsoleip",
		   			editable:true,
		   			editrules:{
		   				required:true
		   			}
		   		},
		   		{	/*	存放模組所在的路徑	*/
		   			name:"modulePath",
		   			index:"modulePath",
		   			editable:true,
		   			editrules:{
		   				required:true
		   			}
		   		},
		   		{	/*	登入帳號	*/
		   			name:"loginId",
		   			index:"loginId",
		   			editable:true,
		   			editrules:{
		   				required:true
		   			}
		   		},
		   		{name:"pwd",editable:true,hidden: true, hidedlg: true, editrules:{edithidden:true},edittype:"password"}
		   	],
		   	rowNum: 6,
		   	pager: "#pager",
		   	forceFit: true,
			rownumbers: true,
		   	viewrecords: true,	
			caption: "維護 Web Console 清單"
		}).jqGrid("navGrid","#pager",{add:true,edit:true,del:true,search:false,refresh:false},
			{	
				/* Edit
					按下送出後要完成下列功能
					1. 畫面更新為新輸入的資料
					2. 後端更改新值成功 
				*/
				url: "ManipulateGridWCL",
				mtype: "POST",
				editData:{ 
					bssId: function() { return $("select#bss option:selected").val();},
					subSysId: function() { return $("select#subsys option:selected").val(); },
					currentUser: function() { return $.cookie("userId"); }
				}		
			},
			{	// Add
				url: "ManipulateGridWCL",
				mtype: "POST",
				editData: {
					bssId: function() { return $("select#bss option:selected").val();},
					subSysId: function() { return $("select#subsys option:selected").val(); },
					currentUser: function() { return $.cookie("userId"); }
				}
			},
			{	// Delete
				url: "ManipulateGridWCL",
				mtype: "POST",
				delData: { 
					squadId: function() {
						var sel_id = $("#gd").jqGrid('getGridParam', 'selrow');
						return $("#gd").jqGrid('getCell', sel_id, 'squadId');
					},
					bssId: function() { return $("select#bss option:selected").val();},
					subSysId: function() { return $("select#subsys option:selected").val(); },
					currentUser: function() { return $.cookie("userId"); }
				}
			});
		
			reconfigPermissions('2','gd');
			initPage("維護Web Console");
	}
}).tooltip();
</script>

</head>
<body>
	<div id="header"></div>
	<p>
	<form id="q_form">
		<input type="hidden" id="bssId" name="bssId" />
		
		<input type="hidden" id="envId" name="envId" />
		
		<!-- 用來進行 Update時使用 -->
		<input type="hidden" id="oriHostIP" name="oriHostIP" />
		<input type="hidden" id="oriBssId" name="oriBssId" />
		<input type="hidden" id="oriSubSysId" name="oriSubSysId" />
		<input type="hidden" id="oriPort" name="oriPort" />
		<input type="hidden" id="hostName" name="hostName" />
		
	</form>
	<form id="a_form">
		<input type="hidden" id="fc" name="fc" />	<!-- 供Servlet識別從那個UI來呼叫 (fromCall 縮寫) -->
		<input type="hidden" id="subSysId" name="subSysId" />
		<input type="hidden" id="loginUser" name="loginUser" />
		<input type="hidden" id="isSU" name="isSU" />
	</form>
	<br/>
	<table>
		<tr>
			<th class="right"><label for="bss">系統：</label></th>
			<td><select id="bss">
					<option value="MBMS">MBMS</option>
			</select></td>
		</tr>
		<tr>
			<th class="right"><label for="subsys">子系統：</label></th>
			<td><select id="subsys"><option id='dOpt'>--請選擇--</option></select>
			</td>
		</tr>
	</table>

	<p>
	<hr />
	<p>
	<table id="gd"></table>
	<div id="pager"></div>


</body>
</html>